#include <gata/core/macro.h>
#include <gata/gui/StandardButtonWidget.h>

#include "GS_Logo.h"
#include "../CGame.h"
#include "../ImageManager.h"
#include "../SpriteManager.h"

using namespace gata::graphic;
using namespace gata::gui;

GS_Logo::GS_Logo() : m_masterWidget(0)
{
}

GS_Logo::~GS_Logo()
{
}

bool GS_Logo::isKindOf(int kind)
{
	return kind == STATE_LOGO;
}

void GS_Logo::create()
{
	m_masterWidget = new Widget(0, 50, 50, 700, 500, 0);
	m_masterWidget->setBackgroundColor(0xCCCCCCFF);

	Widget* widget2 = new Widget(m_masterWidget, 50, 50, 300, 200, 0);
	Widget* widget3 = new Widget(m_masterWidget, 250, 150, 300, 200, 0);
	Widget* widget4 = new Widget(m_masterWidget, 100, 200, 300, 200, 0);
	Widget* widget5 = new Widget(m_masterWidget, 80, 300, 400, 170, 0);
	
	widget2->setBackgroundColor(0xFF0000FF);
	widget2->setMoveType(MT_INSIDE_DAD);
		StandardButtonWidget* buttonOK;
		StandardButtonWidget* buttonCancel;
		buttonOK = new StandardButtonWidget(widget2, 10, 60, 100, 50, this, "OK");
		buttonOK->setMoveType(MT_OUTSIDE_DAD);
		buttonCancel = new StandardButtonWidget(widget2, 150, 70, 130, 50, this, "CANCEL");
		buttonCancel->setMoveType(MT_INSIDE_DAD);

	widget3->setBackgroundColor(0x00FF00FF);
	widget4->setBackgroundColor(0x00FFFFFF);
	widget4->setMoveType(MT_INSIDE_DAD);
	widget5->setBackgroundColor(0xFFFF00FF);

	//
	SpriteManager::getInstance()->getRes(SPRITE_font3_myspr)->setImage(ImageManager::getInstance()->getRes(IMAGE_font3_tga));
}

void GS_Logo::destroy()
{
	SAFE_DEL(m_masterWidget);
}

bool GS_Logo::update()
{
	m_masterWidget->update();
	return g_pGame->isKeyDown(KEY_EXIT);
}

void GS_Logo::render()
{
	g_pGraphic->setClearColor(0);
	//m_masterWidget->render(g_pGraphic);

	/*g_pGraphic->setColor(0xFF0000FF);
	g_pGraphic->fillRect(100, 50, 400, 200);

	g_pGraphic->setColor(0xFFFF00FF);
	g_pGraphic->fillRect(150, 350, 400, 100);*/

	Transform t;
	//t.append(ROTATE_90);
	//t.append(ROTATE_270);

	g_pGraphic->drawImage(ImageManager::getInstance()->getRes(IMAGE_a_tga), 0, 0, 1.0f, 1.0f, &t);
	//g_pGraphic->setColor(0xFFFF00FF);
	//g_pGraphic->fillRect(150, 350, 400, 100);
	//g_pGraphic->drawImage(ImageManager::getInstance()->getRes(IMAGE_mario_large_tga), 0, 0);
	//SpriteManager::getInstance()->getRes(SPRITE_font3_myspr)->drawWrapString(
	//	g_pGraphic,
	//	"Hey everyone, we are so excited to be BACK. New record, music video, and tour right around the corner.",// Can't wait to see you all on the road!\n\nIts with great satistfaction we can announce Marduks return to the southern parts of Sweden. On the 22nd of August Marduk will be appearing in Malmo at the Malmofestivalen. More info at: Malmofestivalen.se\n\nIt's official, Suffocation will be inducted in the Long Island Hall of Fame, October 18, 2012!!!! Good job everyone! Thank you so much for the support. More news to come!\n\nThe 'last gasp' signals, which came from a galaxy 3.9 billion light years away, were X-rays generated by matter heated to millions of degrees and torn apart as the star crossed the black.",
	//	g_pGame->width() >> 1, g_pGame->height() >> 1,
	//	780,
	//	ANCHOR_HCENTER | ANCHOR_VCENTER,
	//	ALIGN_JUSTIFY,
	//	1.17f, 1.5f
	//);

	/*SpriteManager::getInstance()->getRes(SPRITE_font3_myspr)->drawString(
		g_pGraphic,
		"We both young when I first saw you.",
		getGame()->width() / 2, getGame()->height() / 2,
		ANCHOR_HCENTER | ANCHOR_VCENTER,
		0,
		1.5f, 1.5f);*/
}

void GS_Logo::pause()
{
}

void GS_Logo::resume()
{
}

void GS_Logo::actionPerformed(gata::gui::Widget* pSenderWidget)
{

}
